<include file="Public:header" />
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/js/PCASClass.js" type="text/javascript"></script>
<!-- nice-scroll -->
<script src="__PUBLIC__/style/js/plugins/nice-scroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<script src="__PUBLIC__/js/mxcrm_more.js" type="text/javascript"></script>
<style>
body{
	overflow-y: hidden;
}
.option{padding-left:-30px;}
#oDivL_tab_Test3{background-color: #fff;}
</style>
<script>
$(function(){
	var scroll_width = 10;
	$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
	$(window).resize(function(){
		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
		$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width());
		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
	});
	$(".nicescroll").niceScroll({
		cursorcolor: "#999",//#CC0071 光标颜色
	    cursoropacitymax: 0.4, //改变不透明度非常光标处于活动状态（scrollabar“可见”状态），范围从1到0
	    touchbehavior: false, //使光标拖动滚动像在台式电脑触摸设备
	    cursorwidth: scroll_width+"px", //像素光标的宽度
	    cursorborder: "0", //     游标边框css定义
	    cursorborderradius: "3px",//以像素为光标边界半径
	    autohidemode: false, //是否隐藏滚动条
	    zindex:100,
	    background:"#F3F3F5",//滚动条背景色
	});
	$("#tab_Test3").FrozenTable(1,0,2);
	$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width()).css({'zIndex':9});
	$("#oDivL_tab_Test3").css({"background-color":"#fff","border-right":"1px solid #e7eaec"});
	$("#oTableLH_tab_Test3").css({"border-right":"1px solid #e7eaec"});
	$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width).css({'zIndex':9});
})
</script>
<div class="wrapper wrapper-content">
	<include file="Public:alert" />
    <div class="row">
        <div class="col-md-12">
            <div class="ibox float-e-margins">
				<div class="title-bar" style="position: relative;z-index: 99;">
					<div class="row  clearfix" id="title-hide" style="display:none;">
						<ul class="breadcrum pull-left">
							<li>已选中&nbsp;<span id="icheck_num"></span>&nbsp;项</li>
							<li class="single_btn"><a href="javascript:void(0)" id="edit_contract"><i class="fa fa-pencil"></i>&nbsp;编辑</a></li>
							<if condition = "$is_checkper eq 1">
								<li class="single_btn"><a href="javascript:void(0)" id="check_contract"><i class="fa fa-check"></i><span id="to_check" ><input type="hidden" id="is_checked" value="1">&nbsp;审核</span></a></li>
							</if>
							<li class="single_btn business_btn"><a href="javascript:void(0)" id="remind"><i class="fa fa-bell-o"></i>&nbsp;提醒</a></li>
							<li class="single_btn"><a href="javascript:void(0)" id="renew_contract"><i class="glyphicon glyphicon-ok-sign"></i>&nbsp;续约</a></li>
							<if condition ="$_GET['by'] eq 'dqcontact'">
								<li ><a href="javascript:void(0)" id="elide_contract"><i class="glyphicon glyphicon-ban-circle"></i>&nbsp;忽略</a></li>
							</if>
							<li><a id="delete" href="javascript:void(0)"><i class="fa fa-times"></i>&nbsp;删除</a></li>
							<li class="last_li"><big><a class="fa fa-times pull-right" id="back-show"></a></big></li>
						</ul>
					</div>
					<div class="row" id="title-show">
						<ul class="nav pull-left" style="margin:2px 0 0 15px;">
							<a href="{:U('contract/add')}" class="btn btn-primary btn-sm pull-left" style="margin-right:8px"><i class="fa fa-plus-circle"></i>&nbsp; 添加合同</a>
						</ul>
						<form class="form-inline" id="" action="" method="get">
						<ul class="breadcrum pull-right" style="margin-bottom: 0px">
							<li>
								<div class="input-group" style="margin-right: 10px;margin-bottom: 5px;">
									<select class="form-control" onchange="window.open(this.options[this.selectedIndex].value,target='_self')" >
										<option value="{:U('contract/index','by=me&'.$by_parameter)}" <if condition = "$_GET['by'] eq 'me' || $_GET['by'] eq ''">selected="selected"</if>>我的合同</option>
										<option value="{:U('contract/index','by=sub&'.$by_parameter)}" <if condition = "$_GET['by'] eq 'sub'">selected="selected"</if>>下属合同</option>
										<option value="{:U('contract/index','by=all&'.$by_parameter)}" <if condition = "$_GET['by'] eq 'all'">selected="selected"</if>>全部合同</option>
									</select>
								</div>
							</li>
							<li>
								搜索：
								<div class="input-group">
									<input type="hidden" name="m" value="contract"/>
									<input type="hidden" name="a" value="index"/>
									<input type="hidden" name="condition" value="contains"/>
									<input type="hidden" name="field" value="number"/>
									<input type="hidden" name="by" value="{$by}"/>
									<input type="hidden" name="contract_checked" value="{$_GET['contract_checked']}"/>
									<input id="short_search" type="text" style="width:210px;" placeholder="合同编号/名称/客户名/项目名" onkeydown='if(event.keyCode==13) {$("#short_search_btn").trigger("click");return false;}' class="form-control input-sm" name="search" <if condition = "$_GET['field'] eq 'name'">value="{$_GET['search']}"</if>/>

									<if condition="$_GET['field']">
										<!-- 导出相关 -->
										<input type="hidden" name="this_page" value="{$this_page}" />
										<input type="hidden" name="act" id="act" value="index"/>
										<input type="hidden" name="daochu" id="daochu"/>
										<input type="hidden" name="selectexcelxport" id="selectexcelxport"/>
										<input type="hidden" name="current_page" id="current_page" value=""/>
										<input type="hidden" name="export_limit" id="export_limit" value=""/>
										<!-- 导出相关 -->
									</if>

									<span class="input-group-btn">
										<button class="btn btn-default btn-search" id="short_search_btn" type="submit"><i class="fa fa-search"></i></button>
									</span>
								</div>
								&nbsp;&nbsp;<a title="高级搜索" href="javascript:void(0)" id="search_type" class="btn btn-white btn-bitbucket"><i class="fa fa-filter" style="color: #D8E3EF;"></i></a>
							</li>
						</ul>
						</form>
					</div>
				</div>
				<div class="ibox-content clearfix" id="table_container" style="z-index: 1;">
					<form id="form1" action="" method="Post" style="position:relative;">
						<div id="table_div" class="nicescroll">
						<if condition="$list eq null">
							<include file="Public:nodata" />
						<else/>
							<table class="table table-hover table-striped table_thead_fixed" id="tab_Test3">
								<tr id="childNodes_num" class="tabTh">
									<td style="width:30px;padding-left: 20px">
										<div class="checkbox checkbox-primary">
											<input type="checkbox" class="check_all"/>
											<label for=""></label>
										</div>
									</td>
									<td style="width: 26px;">&nbsp;</td>
									<volist name="field_array" id="vo">
										<if condition = "$vo['field'] eq 'contract_name'" >
											<td>合同编号</td>
											<td>{$vo.name}</td>
										<else />
											<td>{$vo.name}</td>
										</if>
									</volist>
									<td>签约人</td>
									<td>审批人</td>
									<td>状态</td>
								</tr>
								<volist name="list" id="vo">
									<tr class="controls_tr">
										<td style="width:30px;padding-left: 20px">
											<div class="checkbox checkbox-primary">
												<input name="contract_id[]" class="check_list" type="checkbox" value="{$vo.contract_id}" <if condition="$vo['check_per']">rel1="1"<else/>rel1="0"</if>/>
												<label for=""></label>
											</div>
										</td>
										<td>
											<a href="javascript:void(0);" class="remind_view" rel="{$vo['contract_id']}">
												<span class="fa fa-bell-o {$vo['remind_time'] > time() ? '':'hide'}" id="remind_view_{$vo['contract_id']}" style="font-size:16px;color:orange"></span>
											</a>
										</td>
										<volist name="field_array" id="v">
											<if condition = "$v['field'] eq 'contract_name'">
												<td>
													<a href="{:U('contract/view','id='.$vo['contract_id'])}">{$vo.number}</a>
													<if condition="$vo['contract_status'] eq 1">
														<span style="color:green">(已续约)</span>
													</if>
													<if condition="$vo['is_checked'] eq '1' && $vo['renew_contract_id'] gt 0">(续约合同)</if>
												</td>
												<td>
													<a href="{:U('contract/view','id='.$vo['contract_id'])}">{$vo.contract_name}</a>
												</td>
											<elseif condition = "$v['field'] eq 'customer_id'" />
												<td>
													<a href="{:U('customer/view','id='.$vo['customer_id'])}">{$vo.customer_name}</a>
												</td>
											<elseif condition = "$v['field'] eq 'business_id'" />
												<td>
													<a href="{:U('business/view','id='.$vo['business_id'])}">{$vo.business_name}</a>
												</td>
											<else />
												<td>
													<span style="color:#{$v['color']}">
														<if condition="$v['form_type'] eq 'datetime'">
															<if condition="$vo[$v['field']]">
																{$vo[$v['field']]|date='Y-m-d',###}
															</if>
														<else />
															{$vo[$v['field']]}
														</if>
													</span>
												</td>
											</if>
										</volist>
										<td>
											<notempty name="vo.owner_role_id">
												<a class="role_info" rel="{$vo.owner_role_id}" href="javascript:void(0)">{$vo.owner_name}</a>
											</notempty>
										</td>
										<td>
											<notempty name="vo.examine_role_info">
												<a class="role_info" rel="{$vo['examine_role_info']['role_id']}" href="javascript:void(0)">{$vo['examine_role_info']['full_name']}</a>
											</notempty>
										</td>
										<td class="check_badge">
											<if condition="$vo['is_checked'] eq '2'">
												<span class="fa fa-circle" style="color:#F5715F"></span>&nbsp;&nbsp;&nbsp;拒绝
											<elseif condition="$vo['is_checked'] eq '1'"/>
												<span class="fa fa-circle" style="color:#7CCA4E"></span>&nbsp;&nbsp;通过
											<elseif condition="$vo['is_checked'] eq '3'"/>
												<span class="fa fa-circle" style="color:#FF6600"></span>&nbsp;&nbsp;&nbsp;审批中
											<else />
												<span class="fa fa-circle" style="color:#F5CA00"></span>&nbsp;&nbsp;&nbsp;待审
											</if>
										</td>
									</tr>
								</volist>
							</table>
						</if>
						</div>
						<div id="tfoot_div" class="clearfix">
							<div class="clearfix" id="tfoot_page">
								<if condition="$fields_search">
									<span class="pull-left" style="margin-left:25px;margin-top:10px;">本次搜索结果<span style="color:#F8AC59"> {$count} </span>条数据<a href="{:U('contract/index')}" class="btn" style="background:#fff;border:1px solid #ccc;margin-left:10px;color:#999;" id="clearnumber">清除搜索条件</a></span>
								</if>
								{$page}<include file="Public:listrows" />
							</div>
						</div>
					</form>
				</div>
    		</div>
        </div>
    </div>
</div>
<div style="display:none" id="dialog-field-search" title="高级搜索">
	<form class="form-inline" id="searchForm" action="" method="get">
		<div id="search_add" style="width:650px;float:left;">
		<if condition="$_GET['field'] eq ''">
			<input type="hidden" name="this_page" value="{$this_page}" />

			<input type="hidden" name="m" value="contract"/>
			<input type="hidden" name="act" id="act" value="index"/>
			<input type="hidden" name="daochu" id="daochu"/>
			<input type="hidden" name="selectexcelxport" id="selectexcelxport"/>
			<input type="hidden" name="current_page" id="current_page" value=""/>
			<input type="hidden" name="export_limit" id="export_limit" value=""/>
			<if condition="$Think.get.by neq null">
				<input type="hidden" name="by" value="{$Think.get.by}"/>
			</if>
			<input type="hidden" name="contract_checked" value="{$_GET['contract_checked']}"/>
		</if>
		<empty name="fields_search">
			<div id="con_search_1" style="float:left;width:650px;margin:0 10px 0 10px;">
				<ul class="nav pull-left" style="margin:0px 0 0 23px;width:650px">
					<li class="pull-left">
						<select id="field_1" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition(1)" >
							<option class="" value="name">--请选择条件--</option>
							<option class="word" value="number">{:L('CONTRACT_NO')}</option>
							<option class="contract_check" value="is_checked">审核状态</option>
							<option class="role" value="owner_role_id">合同签约人</option>
							<option class="word" value="customer_name">客户名称</option>
							<option class="date" value="create_time">{:L('CREATION_DATE')}</option>
							<option class="date" value="update_time">{:L('MODIFICATION_DATE')}</option>
						</select>&nbsp;&nbsp;
					</li>
					<li class="pull-left" id="conditionContent_1">
						<select id="condition_1" style="width:auto" class="form-control input-sm new-select" onchange="changeSearch()" name="name[condition]">
							<option value="contains">{:L('CONTAINS')}</option>
							<option value="is">{:L('IS')}</option>
							<option value="start_with">{:L('START_WITH')}</option>
							<option value="end_with">{:L('END_WITH')}</option>
							<option value="is_empty">{:L('IS_EMPTY')}</option>
						</select>&nbsp;&nbsp;
					</li>
					<li class="pull-left" id="searchContent_1">
						<input id="search_1" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="name[value]"/>&nbsp;&nbsp;
					</li>
				</ul>
			</div>
			<?php $max_key = 1;?>
		<else />
			<volist name="fields_search" key="key1" id="vo">
				<div id="con_search_{$key1}" style="float:left;width:650px;margin:10px 10px 0 10px;">
					<div id="rem_{$key1}" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="{$key1}" title="移除"><span class="fa fa fa-times-circle"></span></a></div>
					<ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px;">
						<li class="pull-left">
							<select id="field_{$key1}" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition({$key1})" >
								<option class=""  value="name">--请选择条件--</option>
								<option class="word" <if condition = "$vo['field'] eq 'number'">selected="selected"</if> value="number">{:L('CONTRACT_NO')}</option>
								<option class="contract_check" <if condition = "$vo['field'] eq 'is_checked'">selected="selected"</if> value="is_checked">审核状态</option>
								<option class="role" <if condition = "$vo['field'] eq 'owner_role_id'">selected="selected"</if> value="owner_role_id">合同签约人</option>
								<option class="word" <if condition = "$vo['field'] eq 'customer_name'">selected="selected"</if> value="customer_name">客户名称</option>
								<option class="date" <if condition = "$vo['field'] eq 'create_time'">selected="selected"</if> value="create_time">{:L('CREATION_DATE')}</option>
								<option class="date" <if condition = "$vo['field'] eq 'update_time'">selected="selected"</if> value="update_time">{:L('MODIFICATION_DATE')}</option>
							</select>&nbsp;&nbsp;
						</li>
						<li class="pull-left" id="conditionContent_{$key1}">
						<if condition="$vo.form_type eq 'number'">
							<select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
								<option value="gt" <if condition="$_GET[$vo['field']][condition] eq 'gt'">selected="selected"</if>>{:L('GT')}</option>
								<option value="lt" <if condition="$_GET[$vo['field']][condition] eq 'lt'">selected="selected"</if>>{:L('LT')}</option>
								<option value="eq" <if condition="$_GET[$vo['field']][condition] eq 'eq'">selected="selected"</if>>{:L('EQ')}</option>
								<option value="neq" <if condition="$_GET[$vo['field']][condition] eq 'neq'">selected="selected"</if>>{:L('NEQ')}</option>
							</select>
						<elseif condition="$vo.field eq 'owner_role_id' || $vo.field eq 'is_checked' || $vo.form_type eq 'datetime'"/>
						<elseif condition="$vo.form_type eq 'box'" />
							<span id="{$vo['field']}"></span>
							<script type="text/javascript">
								var b = '{$vo[field]}';
								var c = 'product';
								$.ajax({
									type:'get',
									url:'index.php?m=setting&a=boxfield&model='+c+'&field='+b,
									async:false,
									success:function(data){
										options = '';
										$.each(data.data, function(k, v){
											if('{$vo.value}' == v){
												select = 'selected';
											}else{
												select = '';
											}
											options += "<option value='"+v+"' "+select+">"+v+"</option>";
										});
										$("#{$vo['field']}").html('<select class="{$vo["field"]} form-control input-sm" style="width:auto" name="{$vo["field"]}[value]" ><option value="">--{:L('PLEASE_CHOOSE')}--</option>' + options + '</select>&nbsp;&nbsp;');
									},
									dataType:'json'
								});
								<if condition="!empty($_GET[$vo['field']])">
									$(".{$vo['field']} option[value='{$_GET[$vo['field']]}']").attr('selected','selected');
								</if>
							</script>
						<elseif condition="$vo.form_type eq 'address'" />
							<select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
								<option value="contains" <if condition="$_GET[$vo['field']][condition] eq 'contains'">selected="selected"</if>>{:L('IN')}</option>
								<option value="not_contain" <if condition="$_GET[$vo['field']][condition] eq 'not_contains'">selected="selected"</if>>{:L('NOTIN')}</option>
							</select>
							<select name="{$vo['field']}[state]" class="form-control input-sm" id="state" style="width:135px;"></select>
							<select name="{$vo['field']}[city]" class="form-control input-sm" id="city" style="width:110px;"></select>
							<select name="{$vo['field']}[area]" class="form-control input-sm" id="area" style="width:110px"></select>
							<input type="text" id="search" name="{$vo['field']}[search]" value="{$_GET[$vo['field']][search]}" class="form-control input-sm" placeholder="{:L('THE_STREET_INFORMATION')}" class="input-large">
							<script type="text/javascript">
								 new PCAS("{$vo['field']}[state]","{$vo['field']}[city]","{$vo['field']}[area]","<php>echo $_GET[$vo['field']]['state'];</php>","<php>echo $_GET[$vo['field']]['city'];</php>","<php>echo $_GET[$vo['field']]['area'];</php>");
							</script>
						<else />
							<select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
								<option value="contains" <if condition="$_GET[$vo['field']][condition] eq 'contains'">selected="selected"</if>>{:L('INCLUDE')}</option>
								<option value="not_contain" <if condition="$_GET[$vo['field']][condition] eq 'not_contain'">selected="selected"</if>>{:L('EXCLUSIVE')}</option>
								<option value="is" <if condition="$_GET[$vo['field']][condition] eq 'is'">selected="selected"</if>>{:L('YES')}</option>
								<option value="isnot" <if condition="$_GET[$vo['field']][condition] eq 'isnot'">selected="selected"</if>>{:L('NO')}</option>
								<option value="start_with" <if condition="$_GET[$vo['field']][condition] eq 'start_with'">selected="selected"</if>>{:L('BEGINNING_CHARACTER')}</option>
								<option value="end_with" <if condition="$_GET[$vo['field']][condition] eq 'end_with'">selected="selected"</if>>{:L('TERMINATION_CHARACTER')}</option>
								<option value="is_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_empty'">selected="selected"</if>>{:L('MANDATORY')}</option>
								<option value="is_not_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_not_empty'">selected="selected"</if>>{:L('ISNOTEMPTY')}</option>
							</select>
						</if>
						</li>
						<li class="pull-left" id="searchContent_{$key1}" style="margin-left:5px;">
						<if condition="$vo.form_type neq 'box' && $vo.form_type neq 'address'">
							<if condition="$vo.form_type eq 'datetime'">
								<input id="start_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[start]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][start]}" rel="contract"/> 至 <input id="end_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[end]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][end]}" rel="contract"/>
							<elseif condition="$vo['field'] eq 'owner_role_id'"/>
								<span id="owner_role_search" rel="{$key1}" rel1="{$vo['field']}[value]" rel2="{$_GET[$vo['field']][value]}"/>
								<script type="text/javascript">
									var key_id = $('#owner_role_search').attr('rel');
									var search_owner_role_id = $('#owner_role_search').attr('rel1');
									var owner_roleid = $('#owner_role_search').attr('rel2');
									$.ajax({
										type:'get',
										url:'index.php?m=user&a=getrolelist&module=contract&action=index',
										async:false,
										success:function(data){
											options = '';
											$.each(data.data, function(k, v){
												options += '<option value="'+v.role_id+'" checkedit>'+v.user_name+' ['+v.department_name+'-'+v.role_name+'] </option>';
											});
											$("#searchContent_"+key_id+"").html('<select class="selectpicker show-tick form-control input-sm" data-live-search="true" id="search_'+key_id+'" name="'+search_owner_role_id+'" style="width:auto">' + options + '</select>');
											/*$('#search_'+key_id).selectpicker('val',owner_roleid);
											$('#search_'+key_id).selectpicker('refresh');*/
											var owner_roleid = "{$_GET[$vo['field']][value]}";
											$('#search_'+key_id+' option[value='+owner_roleid +']').prop('selected',true);

										},
										dataType:'json'
									});
								</script>
							<elseif condition="$vo['field'] eq 'is_checked'"/>
								<select class="form-control input-sm" style="width:auto" name="{$vo['field']}[value]">
									<option value="0">待审</option>
									<option value="1" <if condition ="$_GET[$vo['field']][value] eq 1">selected="selected"</if> >通过</option>
									<option value="2" <if condition ="$_GET[$vo['field']][value] eq 2">selected="selected"</if> >拒绝</option>
									<option value="3" <if condition ="$_GET[$vo['field']][value] eq 3">selected="selected"</if> >审批中</option>
								</select>
							<else/>
								<input name="{$vo['field']}[value]" type="text" class="form-control input-sm" class="{$vo['form_type']}" value="{$_GET[$vo['field']][value]}" rel="product">
							</if>
						</if>
						</li>
					</ul>
				</div>
				<?php $max_key = $key1;?>
			</volist>
		</empty>
		</div>
		<div class="clearfix"></div>
		<div style="margin-left: 35px;margin-top:0px;"><a href="javascript:void(0);" style="display: -moz-stack;margin: 30px 0px 0px; font-size: 12px; color: rgb(62, 133, 233);" id="add_btn">+添加筛选条件</a>
		</div>
	</form>
</div>
<div style="display:none" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none" id="dialog-check-contract" title="合同审核">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none" id="dialog-remind" title="提醒">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div style="display:none" id="dialog-remind_view" title="提醒内容">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
/*让复选框默认取消选择*/
var is_receivables = '{$is_receivables}';
$(':checkbox').prop('checked', false);

$('#is_agree').change(function(){
	var agree_id = $(this).val();
	if(agree_id == 1){
		$('.is_show').show();
		if(is_receivables == 0 || is_receivables == ''){
			$('#pay_times').hide();
		}
	}else{
		$('.is_show').hide();
	}
});

$('.openrecycle').click(function(){
	var is_receivables = $("input[name='is_receivables']:checked").val();
	if(is_receivables == 1){
		$('#pay_times').show();
	}else{
		$('#pay_times').hide();
	}
});

//续签合同
$("#renew_contract").click(function(){
	window.location.href="{:U('contract/add', 'old_contract_id=')}"+$(this).attr('rel');
});

//忽略提醒
$("#elide_contract").click(function(){
	var id_array = new Array();
	$("input.check_list:checked").each(function(){
		id_array.push($(this).val());
	});
	if(id_array.length == 0){
		alert_crm('您没有选中任何合同！');
		return false;
	}
	swal({
		title: "确定要忽略合同提醒吗？",
		type: "warning",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		closeOnConfirm: false
	},
	function(){
		$.ajax({
			type:'post',
			url: "{:U('contract/elide_edit')}",
			data: {contract_ids: id_array},
			async: false,
			success: function (data) {
				if (data.status == 1) {
					swal("忽略成功！", "您已经忽略了该合同提醒！", "success");
					location.reload();
				}else{
					swal({
						title: "操作失败！",
						text:data.info,
						type: "error"
					})
					return false;
				}
			},
			dataType: 'json'
		});
	});
});

$("#edit_contract").click(function(){
	window.location.href="{:U('contract/edit', 'id=')}"+$(this).attr('rel');
});

$("#check_contract").click(function(){
	var is_checked = $('#is_checked').val();
	var id = $(this).attr('rel');
	if(is_checked == 1){
		$('#dialog-check-contract').dialog('open');
		$('#dialog-check-contract').load('{:U("contract/check","contract_id=")}'+id);
	}else{
		swal({
			title: "确定要撤销审核吗？",
			type: "warning",
			showCancelButton: true,
			confirmButtonColor: "#DD6B55",
			confirmButtonText: "确定",
			closeOnConfirm: false
		},
		function(){
			window.location.href="{:U('contract/revokeCheck', 'id=')}"+id;
		});
	}
});

$("#dialog-check-contract").dialog({
	autoOpen: false,
	modal: true,
	width: 444,
	maxHeight: 460,
	position: ["center",100] ,
	buttons: {
		"确定": function () {
			var is_agree = $('#is_agree').val();
			var openrecycle2 = $('#openrecycle2:checked').val();
			var examine_role_id = $('#examine_role_id').val();
			if (is_agree == 1 && openrecycle2 == 1) {
				if (examine_role_id == '') {
					alert_crm('请选择下一审批人！');
					return false;
				}
			}
			$('#contract_dialog').submit();
			$(this).dialog("close");
		},
		"取消": function () {
			$(this).dialog("close");
		}
	},
	close: function() {
    	$(this).html('');
    }
});

$("#short_search").val('{$Think.get.search}');

if ("{:C('isMobile')}" == "1") {
	width = $('#table_container').width() * 0.9;
} else {
	width = 800;
}

$("#dialog-role-info").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 550,
	position: ["center",100]
});

/*添加筛选条件*/
var m = {$max_key};
$('#add_btn').click(function(){
	m += 1;
    $('#search_add').append('<div id="con_search_'+m+'" style="float:left;width:650px;padding-top:10px;margin:0px 10px 0 10px;"><div  id="rem_'+m+'" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="'+m+'" title="移除"><span class="fa fa-times-circle"></span></a></div>&nbsp;<ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px"><li class="pull-left"><select id="field_'+m+'"  style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition('+m+')" name=""><option class="" value="name">--请选择条件--</option><option class="word" value="number">{:L('CONTRACT_NO')}</option><option class="role" value="owner_role_id">合同签约人</option><option class="word" value="customer_name">{:L('CUSTOMER')}名称</option><option class="contract_check" value="is_checked">审核状态</option><option class="date" value="create_time">{:L('CREATION_DATE')}</option><option class="date" value="update_time">{:L('MODIFICATION_DATE')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="conditionContent_'+m+'"><select id="condition_'+m+'" style="width:auto" class="form-control input-sm new-select" name="condition" onchange="changeSearch()"><option value="contains">{:L('CONTAINS')}</option><option value="is">{:L('IS')}</option><option value="start_with">{:L('START_WITH')}</option><option value="end_with">{:L('END_WITH')}</option><option value="is_empty">{:L('IS_EMPTY')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="searchContent_'+m+'"><input id="search_'+m+'" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="search"/>&nbsp;&nbsp;</li></ul></div>');
});

$(document).on('click','.rem_search',function(){
	var num = $(this).attr('rel');
	$('#con_search_'+num).remove();
});

// 筛选重复判断
var dosearch = 1;
function doh(){
	var ary = new Array();
	var field_name = '';
	var is_submit = 1;
	$('.field_name').each(function(k, v){
		field_name = $(this).find("option:selected").val();
		if(jQuery.inArray(field_name,ary) >= 0){
			is_submit = 0;
			swal({
				title: "筛选条件中有重复项！",
				text: "",
				type: "error"
			});
			dosearch = 0;
			return false;
		}
		ary[k] = field_name;
	})
	if(is_submit == 1){
		$("#searchForm").submit();
	}
}

$("#dialog-field-search").dialog({
	autoOpen: false,
	width: 700,
	modal: true,
	height: 500,
	position: ["center",100],
	buttons: {
		"确定": function () {
			doh();
			if(dosearch == 1){
				$(this).dialog("close");
			}
		},
		"取消": function () {
			$(this).dialog("close");
		}
	}
});

$("#search_type").click(function(){
	$("#dialog-field-search").dialog('open');
});

$('#delete').click(function(){
	var id_array = new Array();
	$("input.check_list:checked").each(function(){
		id_array.push($(this).val());
	});
	if(id_array.length == 0){
		alert_crm('您没有选中任何合同！');
		return false;
	}
	swal({
		title: "您确定要删除合同信息吗？",
			text: "删除后将无法恢复，请谨慎操作！",
		type: "warning",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "是的，我要删除！",
        cancelButtonText:'让我再考虑一下…',
        closeOnConfirm:false,
        closeOnCancel:false
	},
	function(isConfirm){
        if (isConfirm) {
        	$.ajax({
	            type:'post',
	            url: "{:U('contract/delete')}",
	            data: {contract_id: id_array},
	            async: false,
	            success: function (data) {
					if (data.status == 1) {
						swal("删除成功！", "您已经永久删除了信息！", "success");
						location.reload();
					}else{
						swal({
							title: "操作失败！",
							text:data.info,
							type: "error"
						})
						return false;
					}
	            },
	            dataType: 'json'
	        });
        } else {
            swal("已取消","您取消了删除操作！","error");
        }
    });
});

$("#dosearch").click(function(){
	result = checkSearchForm();
	if(result){
		$("#act").val('search');$("#searchForm").submit();
	}
});

$(".role_info").click(function(){
	$role_id = $(this).attr('rel');
	$('#dialog-role-info').dialog('open');
	$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
});

$("#dialog-remind").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100],
	buttons: {
		"确定": function () {
			if($('#dialog_content').val() == ''){
				alert_crm("请填写提醒内容！");
				$("#dialog_content").focus();
			}else{
				$('#remind_form').submit();
				$(this).dialog("close");
			}
		},
		"取消": function () {
			$(this).dialog("close");
		}
	},
	close: function() {
    	$(this).html('');
    }
});

$("#dialog-remind_view").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight: 400,
	position: ["center",100],
	buttons: {
		"删除": function () {
			swal({
				title: "您确认删除吗？" ,
				type: "warning",
				showCancelButton: true,
				confirmButtonColor: "#DD6B55",
				confirmButtonText: "确定",
				closeOnConfirm: false
			},
			function(){
				var dislog_module_id = $('#dislog_module_id').val();
				var dislog_module = $('#dislog_module').val();
				$.ajax({
		            type:'post',
		            url: "{:U('remind/delete')}",
		            data: {module_id: dislog_module_id,module: dislog_module},
		            async: false,
		            success: function (data) {
						if (data.status == 1) {
							$('#remind_view_'+dislog_module_id).addClass('hide');
							swal("操作成功！", "提醒删除成功！", "success");
							$("#dialog-remind_view").dialog("close");
						} else {
							swal({
								title: "操作失败！",
								text:data.info,
								type: "error"
							})
							return false;
						}
		            },
		            dataType: 'json'
		        });
				// $("#dialog_remind").submit();
				// $(this).dialog("close");
			});
		},
		"取消": function () {
			$(this).dialog("close");
		}
	},
	close: function() {
    	$(this).html('');
    }
});

$("#remind").click(function(){
	var contract_id = $(this).attr('rel');
	$('#dialog-remind').dialog('open');
	$('#dialog-remind').load("{:U('remind/add','module=contract&module_id=')}"+contract_id);
});

$(".remind_view").click(function(){
	var contract_id = $(this).attr('rel');
	$('#dialog-remind_view').dialog('open');
	$('#dialog-remind_view').load("{:U('remind/view','module=contract&module_id=')}"+contract_id);
});
</script>
<include file="Public:footer" />
